<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>矩阵转置</title>
</head>
<body>
<script>
    var p=[[1,2,3],[4,5,6],[7,8,9]];
    var row=p.length;
    var col=p[0].length;
    var arr=[[]];
    for(var i=0;i<row;i++){
        for(var j=0;j<col;j++){
            arr.push(p[j][i]);
        }
    }
    console.log(arr);
</script>
</body>
</html>